#include <stdio.h>
#include <stdlib.h>
#define MAXN 1000
int is_valid_sequence(int m, int n, int sequence[]) {
    int stack[MAXN], top = -1;
    int current = 1; 
    for (int i = 0; i < n; i++) {
        int target = sequence[i];
        // Push numbers onto stack
        while (current <= target) {
            if (top + 1 >= m) return 0; 
            stack[++top] = current++; 
        }
        if (stack[top] == target) {
            top--; 
        } else {
            return 0; 
        }
    }
    return 1;// The sequence is valid
}

int main() {
    int m, n, k;
    scanf("%d %d %d", &m, &n, &k);
    int sequence[MAXN];
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &sequence[j]);
        }
        if (is_valid_sequence(m, n, sequence)) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}
